package com.demo.user.util.page;

import org.apache.commons.lang3.StringUtils;

/**
 * @author xxh
 */
public class OrderByUtil {

    public static String filterOrderBy(String orderBy) {

        if (StringUtils.isBlank(orderBy)) {
            return "";
        }

        OrderByColumnEnum columnEnum = OrderByColumnEnum.fromColumn(orderBy);
        if (columnEnum != null) {
            return columnEnum.getColumn();
        }
        return "";
    }

    public static String filterOrderType(String orderType) {

        if (StringUtils.isBlank(orderType)) {
            return "";
        }
        OrderEnum orderEnum = OrderEnum.fromType(orderType);

        if (orderEnum != null) {
            return orderEnum.getOrderType();
        }

        return "";
    }
}
